require 'rubygems'
require 'test/unit'
require '.\lib\fpr_exd.rb'
require 'zip/zipfilesystem'
require 'rexml/document'
include REXML

class TestFpr < Test::Unit::TestCase
	
	def test_cleanup
		a = FprExd.new("OTL.fpr")
		a.cleanup
	end
	
	#test initialize
	def test_un_zip
		a = FprExd.new("OTL.fpr")
		a.unzip
	end

	#test initialize
	def test_run
		a = FprExd.new("OTL.fpr")
		a.run
	end

	#test xml creation
	def test_xml
		doc = Document.new
		doc.add_element('requests')
		entry = Element.new('request')
		entry.attributes["method"] = "GET"
		entry.attributes["scheme"] = "http"
		entry.attributes["httpVersion"] = 'HTTP/1.1'
		entry.attributes["host"] = "127.0.0.1"
		entry.attributes["port"] = "80"
		entry.attributes["path"] = "sd"
		entry.attributes["boundary"] = ""
		entry.attributes["pathQuerySeparator"] = "?"
		entry.attributes["japEncoding"] = "0"

		headers =[
			{'Accept'=>'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*'},
			{'Referer'=>'http://127.0.0.1:80/'},
			{'Accept-Language'=>'en'},
			{'UA-CPU'=>'x86'},
			{'User-Agent'=>'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)'},
			{'Host'=>'127.0.0.1'},
			{'Connection'=>'Keep-Alive'}
		]

		headers.each do |x|
			header_entry = Element.new('header')
			header_entry.attributes["name"]= x.keys[0]
			header_entry.attributes["value"]=x.values[0]
			entry.add_element header_entry
		end

		doc.root.add_element entry
		doc.write($stdout,2)
		

	end

	
end
